package com.spring.cardapi.web.controller;



import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.codehaus.jackson.map.util.JSONPObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;




//import com.spring.iosservice.web.service.IosQuestService;
import com.spring.cardapi.web.service.CardApiService;
import com.spring.cardapi.web.service.ContractService;
import com.spring.security.core.util.ApplicationUtils;
@Controller
@RequestMapping(value = "/contract")
public class ContractController {
	
	@Resource
	private CardApiService cardApiService;
	
	@Resource
	private ContractService contractService;	
	
	//查看合同列表
	@RequestMapping(value = "/getContractList")
	@ResponseBody
    public Object getContractList(String token,String contractTypeCode,
			 String pageSize, String pageIndex, String skip, String rows,String callback) {
   
        Map<String, Object> m = new HashMap<String, Object>();
		try {

			m  = contractService.getContractList(token, contractTypeCode, pageSize, pageIndex, skip, rows);
					
		} catch (Exception e) {
			m.put(ApplicationUtils.STATUS, "0");
			m.put(ApplicationUtils.MSG, "系统异常");
			e.printStackTrace();
		}
    	
    	if(ApplicationUtils.isNotNull(callback)){
        	return new JSONPObject(callback, m);
        }else{
        	return m;
        }     
        
    }
		
	
	//查看合同列表
	@RequestMapping(value = "/deleteContract")
	@ResponseBody
    public Object deleteContract(String contractID,String callback) {
   
        Map<String, Object> m = new HashMap<String, Object>();
		try {

			m  = contractService.deleteContract(contractID);
					
		} catch (Exception e) {
			m.put(ApplicationUtils.STATUS, "0");
			m.put(ApplicationUtils.MSG, "系统异常");
			e.printStackTrace();
		}
    	
    	if(ApplicationUtils.isNotNull(callback)){
        	return new JSONPObject(callback, m);
        }else{
        	return m;
        }     
        
    }
	
	
}

